package cnpm02.j2ee.group3.logic.dao.impl;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.Query;

import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;

import cnpm02.j2ee.group3.logic.dao.generic.AbstractEntityDaoImpl;
import cnpm02.j2ee.group3.model.EmailTemplate;

@Stateless
@Name("emailTemplateDao")
@AutoCreate
public class EmailTemplateDaoImpl extends AbstractEntityDaoImpl<EmailTemplate>
		implements EmailTemplateDao {

	@SuppressWarnings("unchecked")
	public List<EmailTemplate> selectAll() {
		Query query = getEntityManager().createQuery(SELECT_ALL_QUERY);
		return query.getResultList();
	}

	public EmailTemplate getEmailTemplate(String code, String languageCode) {
		Query query = getEntityManager().createQuery(SELECT_EMAIL_TEMPLATE);
		query.setParameter("code", code);
		query.setParameter("languageCode", languageCode);
		return (EmailTemplate) query.getSingleResult();
	}
}
